package map;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
public class MapDemo2 {
    public static void main(String[] args) {
        Map<String,Integer> map =new HashMap<>();
        map.put("语文",150);
        map.put("数学",149);
        map.put("英语",149);
        map.put("物理",98);
        map.put("历史",99);
        map.put("化学",100);
        System.out.println(map);
        /*
        遍历所有的key
        Set<k> keySet()
         */
        Set<String> keySet =map.keySet();
        for (String key :keySet){
            System.out.println("key："+key);
        }
        Set<Map.Entry<String,Integer>> entrySet =map.entrySet();
        for( Map.Entry<String,Integer> e : entrySet){
            String key =e.getKey();
            Integer value =e.getValue();
            System.out.println(key+"："+value);
        }
        //遍历value
        Collection<Integer> values =map.values();
        for (Integer value :values){
            System.out.println("values:"+value);
        }
        //lambda遍历
        values.forEach(e->System.out.println(e));
        values.forEach(System.out::println);
        map.forEach((k,v)->System.out.println(k+":"+v));
    }
}